package com.homer.commons.sscpprotocol.client.impl;

import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;

import com.homer.commons.sscpprotocol.client.Result;

public class ResultImpl implements Result {
    private Map<String, Object> headers = new HashMap<String, Object>();

    private String content;
    
    private byte[] contentByte;

    public String getContent() {
        return this.content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public byte[] getContentByte() {
        return contentByte;
    }

    public void setContentByte(byte[] contentByte) {
        this.contentByte = contentByte;
    }

    @Override
    public byte[] getContentAsByte() {
        // TODO Auto-generated method stub
        return null;
    }

    public Map<String, Object> getHeaders() {
        return this.headers;
    }

    public Object getHeader(String name) {
        return this.headers.get(name);
    }

    // public int getSuccess() {
    // return ((Integer)getHeader("SUCCESS")).intValue();
    // }

    public void setHeaders(ByteBuffer bb) {
       
        this.headers.put("SYNC_HEAD", bb.get());	
        this.headers.put("MAIN_DEVICE_ID", bb.getInt());
        byte[] sd = new byte[2];
        bb.get(sd);
        this.headers.put("SLAVE_DEVICE_ID", sd);
        this.headers.put("KEY", bb.get());
        this.headers.put("COMMAND_LENGTH", bb.get());
    }
    
    public void setEnds() {
        
        this.headers.put("SYNC_END", 0xA5);	
       
    }

    // public String toString()
    // {
    // return "success=" + getHeader("SUCCESS") + "; msg=" +
    // getHeader("MESSAGE_ID") + "; sequence=" +
    // getHeader("MESSAGE_SEQ") + "; contentLength=" +
    // getHeader("CONTENT_LENGTH") + "; content=" + getContent();
    // }
}
